let id = $this.$util.uuid(); // 表单id
let no = $this.$util.uuid(); // 表单no
let headData = $this.model; // 表头数据
let temp =
    `遗留问题描述：${headData.textarea_1758790167865_jOcnJ}
            来源：${headData.input_1758790197910_r4Z1I}`
let saveObj  ={
    "bill_id": id,
    "create_user_id": headData.create_user_id,
    "create_user_name": headData.create_user_name,
    "create_dept_name": headData.create_dept_name,
    "bill_type": headData.bill_type,
    "create_dept_id": headData.create_dept_id,
    "bill_no":no,
    "create_company_name":  headData.create_company_name,
    "create_date": headData.create_date,
    "create_company_id": headData.create_company_id,
    "number_1711439316655_41L04": 0,//计划工时
    "number_1711439319768_Hzhsj": 0,//文档数量
    "systemSelect_1711504973428_U0If2":  headData.systemSelect_1755851190563_zYcrA,//派发人(表体的提出人就是派发人)
    "systemSelect_1711504973428_U0If2_ID":headData.systemSelect_1755851190563_zYcrA_ID,//派发人ID
    "number_1711505160101_Zy3nM": 0,//任务进度
    "number_1711505281945_eUZOr":0,//里程碑序号
    "input_1711505283971_PgltR": "0",//里程碑
    "number_1711505313898_96ND4": "0",//任务累计工时
    "input_1711518795031_xvIfW": "1",//任务状态
    "input_1711520372633_i4sGc": headData.create_date,//派发时间
    "systemSelect_1711520339026_rFF5K": headData.create_company_id,//派发部门
    "systemSelect_1711520339026_rFF5K_ID": headData.create_company_id,//派发部门id
    "select_1711505903223_YWk8w": "c0ae1698d0ff0544d555151c87a08db2",//任务类型(默认就是问题任务)
    "input_1751171983502_E4gXx": 0,//计划项目编号
    "input_1718345101976_ZNGth": 0,//项目编号
    "selectStr_1718345029613_IWjr8": 0,//选择项目立项
    "selectStr_1718345029613_IWjr8_ID":0,//选择项目立项ID
    "input_1711439260720_6QPqX": headData.textarea_1758790167865_jOcnJ,//任务名称

    "rangePicker_1711439307444_Ftzhm": [ headData.datepicker_1758790225915_kMtSe.format("YYYY-MM-DD") +" 00:00:00", headData.datepicker_1758790244757_9m676.format("YYYY-MM-DD")+" 23:59:59"],//计划时间
    "systemSelect_1711439400905_v5lzI": headData.systemSelect_1760433661010_wWXTa,//审核人
    "systemSelect_1711439400905_v5lzI_ID": headData.systemSelect_1760433661010_wWXTa_ID,//审核人ID
    "systemSelect_1711439399614_qXQ72": headData.systemSelect_1760433597035_E2cer,//负责人//表体的责任人就是任务里面的负责人
    "systemSelect_1711439399614_qXQ72_ID": headData.systemSelect_1760433597035_E2cer_ID,//负责人ID
    "textarea_1755766219698_SuIuk":temp
}

console.log(saveObj)

//钉钉消息推送【字段不是必填项】
let urlDing = $this.$util.getAPI_URL();
let formDataDing=new FormData();
formDataDing.append("systemSelect_1711439399614_qXQ72_ID",headData.systemSelect_1760433597035_E2cer_ID);//执行人Id 字符串','拼接
//formDataDing.append("projectName",$this.model["input_1718345101976_PBcTl"]);//项目名称
formDataDing.append("input_1711439260720_6QPqX",headData.textarea_1758790167865_jOcnJ);//任务名称
formDataDing.append("systemSelect_1711504973428_U0If2",headData.systemSelect_1755851190563_zYcrA);//派发人
formDataDing.append("rangePicker_1711439307444_Ftzhm",[ headData.datepicker_1758790225915_kMtSe.format("YYYY-MM-DD") +" 00:00:00", headData.datepicker_1758790244757_9m676.format("YYYY-MM-DD")+" 23:59:59"]);//任务计划时间
urlDing = urlDing.replace("api", "task/dingMessagePush");
$this.$http.post(urlDing,formDataDing).then((res) => {
    if(res.data.code===280){
        $this.$message.success("钉钉消息推送成功")
    }else {
        $this.$message.errr("系统错误，请联系管理员!!!");
    }
})
let formDataH = new FormData()
formDataH.append("billId",headData.bill_id); //【注：表头id】
const isRes = await $this.$http.post("/formsBusiness/getYFGLWTStatus/",formDataH)
if (isRes.data.code === 280 && isRes.data.data === 2) {
    let files = []
    let formData = new FormData()
    formData.append('obj', JSON.stringify(saveObj))
    formData.append("files", JSON.stringify(files))
    $this.$http.post("/wind/form/save/" + "task" + "/" + "add", formData).then(res => {
        let data=res.data.data
        console.log(data)
    }).catch(e => {
        $this.$message.error(e.message);
    });
}


